<template>
	<view>
		<navView navTitle="开票记录" titleColor="#fff" :isBack="true"></navView>
		<view class="container">
			<view class="list-item" v-for="(item, index) in invoicelist" :key="index"
				@tap="$navTo('/subpkg/invoice/invoiceApply?id=' + item.id + '&contract_id=' + item.relation_id)">
				<view class="content">
					<text class="label">发票抬头：{{ item.title || "暂无" }}</text>
					<text class="date">公司名称：{{ item.company_name || "暂无" }}</text>
					<text class="date">税号：{{ item.tax_number || "暂无" }}</text>
					<text class="date">税率：{{ item.tax_rate || "暂无" }}</text>
					<text class="date">开票时间：{{ item.invoice_date || "暂无" }}</text>
					<text class="date">开票状态：{{ formatCheckStatus(item.check_status) || "暂无" }}</text>
				</view>
				<text class="amount">+{{ item.amount }}</text>
			</view>
			<!-- 如果需要更多列表项，可以循环渲染 -->
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			invoicelist: {},
		}
	},
	onLoad(options) {
		console.log(options, 'option')
		this.id = options.id
		this.getInvoiceList()
	},
	methods: {
		formatCheckStatus(status) {
			const statusMap = {
				0: '待审核',
				1: '审核中',
				2: '审核通过',
				3: '审核未通过',
				4: '已撤销'
			};
			return statusMap[status] || '';
		},
		getInvoiceList() {
			// 调用接口获取付款记录
			this.$request('/addons/qingdong/invoice/getContractInvoices', 'GET', {
				contract_id: this.id
			}).then(res => {
				this.invoicelist = res.data
			})
		}
	}
}
</script>

<style>
.container {
	padding: 20px;
	background: #fff;
	border-radius: 30rpx;
}

.list-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 0;
	border-bottom: 1px solid #e0e0e0;
}

.content {
	display: flex;
	flex-direction: column;
}

.label {
	font-size: 16px;
	font-weight: bold;
	color: #333;
	margin-bottom: 5px;
}

.date {
	font-size: 14px;
	color: #888;
}

.amount {
	font-size: 16px;
	font-weight: bold;
	color: #333;
}

.list-item:last-child {
	border-bottom: none;
}

.btn {
	position: fixed;
	width: 95%;
	background: #008EFF;
	color: #fff;
	border-radius: 50rpx;
	left: 50%;
	transform: translate(-50%);
	bottom: 50rpx;
}
</style>